package thinkingJava.chapter18;

import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import static util.Print.*;
public class PreferencesDemo {
	public static void main(String[] args) throws BackingStoreException {
		Preferences prefs = Preferences.userNodeForPackage(PreferencesDemo.class);
		prefs.put("Location", "0z");
		prefs.put("Footwar", "Ruby Slippers");
		prefs.putInt("Companions", 4);
		prefs.putBoolean("Are there witches?", true);
		int usageCount = prefs.getInt("UsageCount", 0);
		print(usageCount);
		usageCount++;
		prefs.putInt("UsageCount", usageCount);
		for (String key : prefs.keys()) {
			print(key + " : " + prefs.get(key, null));
		}
		print("How many companions does Dorthy have ? " + prefs.getInt("Companions", 0));
	}
}
